home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * (a) (C) 1990 by Adobe Systems Incorporated. All rights reserved.
- *
- * (b) If this Sample Code is distributed as part of the Display PostScript
- * System Software Development Kit from Adobe Systems Incorporated,
- * then this copy is designated as Development Software and its use is
- * subject to the terms of the License Agreement attached to such Kit.
- *
- * (c) If this Sample Code is distributed independently, then the following
- * terms apply:
- *
- * (d) This file may be freely copied and redistributed as long as:
- * 1) Parts (a), (d), (e) and (f) continue to be included in the file,
- * 2) If the file has been modified in any way, a notice of such
- * modification is conspicuously indicated.
- *
- * (e) PostScript, Display PostScript, and Adobe are registered trademarks of
- * Adobe Systems Incorporated.
- *
- * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
- * CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
- * AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
- * ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
- * OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
- * WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
- * WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
- * DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
- * OF THIRD PARTY RIGHTS.
- */
-
- /*
- * iparser.c
- *
- * Version: 2.0
- * Author: Ken Fromm
- * History:
- * 03-07-91 Added this comment.
- */
-
- #import "iinterpreter.h"
- #import "iparserhooks.h"
- #import "ierror.h"
- #import <objc/objc.h>
- #import <streams/streams.h>
-
- extern int yylex();
-
- static char *idp;
-
- typedef void (*VoidProc) ();
-
- #define NUM_PROCS 42
- VoidProc procs[128] = {
- /* 0 */ i_int, i_real, i_string, i_literal, i_name, i_array, i_f, i_s,
- /* 8 */ i_clip, i_T, i_A, i_W, i_AW, i_m, i_lineto, i_L,
- /* 16 */ i_r, i_R, i_l, i_x, i_y, i_X, i_Y, i_c,
- /* 24 */ i_cp, i_w, i_g, i_j, i_d, i_miter, i_cap, i_RGB,
- /* 32 */ i_F, i_FF, i_DF, i_MF, i_IMASK, i_IMAGE, i_BPAGE, i_EPAGE,
- /* 40 */ i_REMAP, i_RECODE
- };
-
-
- char igetc()
- {
- return *idp++;
- }
-
- /*
- * Initializes the parsing interpreter and begins the process.
- */
- BOOL iparse(char **dataptr)
- {
- BOOL error = NO, skip = YES, done = NO;
-
- int token;
-
- idp = *dataptr;
- iinitialize();
-
- while (*idp != 0 && !done)
- {
- if (*idp == '\n')
- idp++;
- else if (!strncmp(idp, "%%", 2))
- {
- idp += 2;
- if (!strncmp(idp, "Trailer", 7))
- done = YES;
- else if (!strncmp(idp, "EndPageSetup", 12))
- skip = NO;
- else if (!strncmp(idp, "PageTrailer", 11))
- skip = YES;
-
- idp = strchr(idp,'\n'); idp++;
- }
- else if (skip)
- {
- idp = strchr(idp,'\n'); idp++;
- }
- else
- {
- token = yylex();
- while (token && !error)
- {
- if (token <= NUM_PROCS)
- {
- (*procs[token-1]) ();
- error = iiferror();
- }
- else
- ierrorlog("Unrecognized token", &error);
-
- if (!error)
- token = yylex();
- else
- ierrordisplay(token);
- }
- }
- }
-
- *dataptr = idp;
-
- return error;
- }
-
-
-